package dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import pojo.StuInfo;

import java.util.List;
import java.util.Optional;

@Repository
public interface StuInfoMapper {

    @Insert("insert into stu_info(id,stu_id,name,sex,clazz,birth,address,postalcode,phone,begin_time,remark)" +
            " values(#{id},#{stuId},#{name},#{sex},#{clazz},#{birth},#{address},#{postalcode},#{phone},#{beginTime},#{remark})")
    Integer add(StuInfo stuInfo);

    @Delete("delete from stu_info where id=#{id}")
    Integer del(String id);

    @Update("update stu_info set name=#{name},sex=#{sex},clazz=#{clazz},birth=#{birth},address=#{address},postalcode=#{postalcode},phone=#{phone},begin_time=#{beginTime},remark=#{remark}" +
            "where stu_id = #{stuId}")
    Integer change(StuInfo stuInfo);

    @Select("select id,stu_id,name,sex,clazz,birth,address,postalcode,phone,begin_time,remark" +
            " from stu_info where clazz = #{clazz}")
    List<StuInfo> getStuByClazz(Integer clazz);

    @Select("select id,stu_id,name,sex,clazz,birth,address,postalcode,phone,begin_time,remark " +
            "from stu_info where stu_id = #{stuId}")
    StuInfo getOneByStuId(Integer stuId);

    @Select("select  id,stu_id,name,sex,clazz,birth,address,postalcode,phone,begin_time,remark " +
            "from stu_info")
    List<StuInfo> getAllStu();

    @Select("select * from stu_info where id = #{id}")
    StuInfo getStuByid(String id);

}
